﻿using System.Collections.Generic;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;

namespace Ue.Qcdz.Domain.Products
{
    public class ProductService
    {
        private static IProductRepository _repository;
        static ProductService()
        {
            ProductService._repository = RepositoryFactory.GetRepository<IProductRepository, Product>();
        }
        public static Product GetProduct(object productKey)
        {
            return ProductService._repository.FindBy(productKey);
        }
        public static IList<Product> GetProduct()
        {
            return ProductService._repository.FindAll();
        }
        public static IDataResult<Product> GetProduct(IDataQuery dataQuery)
        {
            return ProductService._repository.FindBy(dataQuery);
        }
        public static void AddProduct(Product product)
        {
            ProductService._repository.Add(product);
        }

        public static void UpdateProduct(Product product)
        {
            ProductService._repository[product.Key] = product;
        }
    }
}
